package com.yimi.yinhepda.views.fenbo_ziti

import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
import com.yimi.yinhepda.R
import com.yimi.yinhepda.adapter.RecycleAdapter.FenBoZiTiFailAdapter
import com.pda.ym.base.BaseTitleActivity
import com.yimi.yinhepda.entity.response.LoadInfo
import com.yimi.yinhepda.entity.response.ZiTiScanUploadResponse
import kotlinx.android.synthetic.main.activity_fenbo_ziti_fail.*

/**
 * @author: lj
 * Date: 2020/3/14 15:34
 * Description:分拨自提失败列表界面
 */
class FenBoZiTiFailActivity : BaseTitleActivity() {

    private lateinit var mAdapter: FenBoZiTiFailAdapter

    override fun getPageName(): String {
        return "自提失败列表"
    }

    override fun setContentViewId(): Int {
        return R.layout.activity_fenbo_ziti_fail
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        val errorList = intent.getSerializableExtra("errorList") as MutableList<*>

        val loadInfos = mutableListOf<LoadInfo>()
        errorList.forEach {
            it as ZiTiScanUploadResponse.ApplyErrorInfo
            val item = LoadInfo()
            item.waybillNo = it.waybillNo.toString()
            item.remark = it.errorMsg
            loadInfos.add(item)
        }

        mAdapter = FenBoZiTiFailAdapter(this@FenBoZiTiFailActivity, loadInfos)
        rv_fail_list.layoutManager = LinearLayoutManager(this@FenBoZiTiFailActivity, LinearLayoutManager.VERTICAL, false)
        rv_fail_list.adapter = mAdapter

        btn_fail_ok.setOnClickListener {
            finish()
        }
    }

    override fun showBack(): Boolean {
        return false
    }

    override fun setBack() {
    }

    override fun setTitle(): String {
        return pageName
    }

}